package com.chenbei.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chenbei.system.domain.SysUserOrg;
import com.chenbei.system.mapper.SysUserOrgMapper;
import com.chenbei.system.service.ISysUserOrgService;
import org.springframework.stereotype.Service;

@Service
public class SysUserOrgService extends ServiceImpl<SysUserOrgMapper, SysUserOrg> implements ISysUserOrgService {

    @Override
    public void addOrUpdate(SysUserOrg sysUserOrg) {
        LambdaQueryWrapper<SysUserOrg> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysUserOrg::getSysUserId, sysUserOrg.getSysUserId());
        remove(queryWrapper);

        if (sysUserOrg.getOrgId() != null) {
            save(sysUserOrg);
        }
    }
}
